package guoanmaker.operator.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.service.OperatorFinancingServiceNewServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
/**
 * 
    * @ClassName: OperatorFinancingServiceNewController  
    * @Description: 运营后台投融资服务  
    * @author lsy  
    * @date 2017年12月19日 上午8:54:49    
    *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_FINANCING_SERVICE_NEW)
public class OperatorFinancingServiceNewController {
	@Autowired
	private OperatorFinancingServiceNewServiceInterface operatorFinancingServiceNewServiceInterface;
	/**
	 * 
	    * @Title: saveOperatorFinancingServiceNew  
	    * @Description: 保存投融资服务
	    * @param @param inRoundPhone
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "保存投融资服务", notes = "保存投融资服务")
	@PostMapping("saveOperatorFinancingServiceNew")
	public AjaxJson saveOperatorFinancingServiceNew(@RequestBody InRoundPhone inRoundPhone) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			operatorFinancingServiceNewServiceInterface.deleteByCityCodeAndFinancingName(inRoundPhone);
			operatorFinancingServiceNewServiceInterface.saveOperatorFinancingServiceNew(inRoundPhone);
			ajaxJson.setSuccess(true).setStatus(200).setData(null).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findAllOperatorFinancingServiceNew
	    * @Description: 根据cityId 投融资服务名称查询所有
	    * @param @param cityId
	    * @param @param financingName
	    * @return AjaxJson  
	    * @throws
	 */
	@ApiOperation(value = "根据cityId 查询投融资服务", notes = "根据cityId 查询投融资服务")
	@PostMapping("findAllOperatorFinancingServiceNew")
	public AjaxJson findAllOperatorFinancingServiceNew(String cityId, String financingName) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorFinancingServiceNewServiceInterface.findAllOperatorFinancingServiceNew(cityId, financingName)).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findInvestorDisplayById
	    * @Description: 根据金融大咖的id 查询
	    * @param @param financingId
	    * @return AjaxJson  
	    * @throws
	 */
	@ApiOperation(value = "根据id查询金融大咖", notes = "根据id查询金融大咖")
	@PostMapping("findInvestorDisplayById")
	public AjaxJson findInvestorDisplayById(String financingId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorFinancingServiceNewServiceInterface.findInvestorDisplayById(financingId)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: findFinanceProjectById
	    * @Description: 根据金融服务的id 查询
	    * @param @param financingId
	    * @param @return   
	    * @return AjaxJson  
	    * @throws
	 */
	@ApiOperation(value = "根据id查询金融服务", notes = "根据id查询金融服务")
	@PostMapping("findFinanceProjectById")
	public AjaxJson findFinanceProjectById(String financingId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorFinancingServiceNewServiceInterface.findFinanceProjectById(financingId)).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}

}
